// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: V Platform Object
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 82 : TYPE_VPLATFORM

// Function declarations
reserve function VPlatform_DebugDraw
reserve function VPlatform_DebugSpawn

// Static Values

// Tables

function VPlatform_DebugDraw
	DrawSprite(0)
end function


function VPlatform_DebugSpawn
	CreateTempObject(TypeName[V Platform], 0, object.xpos, object.ypos)
end function


event ObjectMain
	GetTableValue(temp1, 14, StageSetup_table9)
	temp1 <<= 8
	temp0 = object.ypos
	temp0 -= temp1
	temp2 = object.value1
	temp2 &= -0x10000
	temp1 = temp0
	temp1 &= -0x10000
	temp1 -= temp2
	temp2 = object.ypos
	object.ypos = object.value1
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -12, 32, 4, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
		if checkResult == 1
			object[currentPlayer].ypos += temp1
		end if
	next
	object.ypos = temp2
	object.value1 = temp0
end event


event ObjectDraw
	DrawSpriteXY(0, object.xpos, object.value1)
end event


event ObjectStartup
	LoadSpriteSheet("SBZ/Objects.gif")
	SpriteFrame(-32, -12, 64, 24, 318, 140)
	SetTableValue(TypeName[V Platform], DebugMode_ObjCount, DebugMode_TypesTable)
	SetTableValue(VPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(VPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
